//
//  LTFFirstTableViewCell.m
//  NeteaseNews
//
//  Created by liutaifeng on 16/4/15.
//  Copyright © 2016年 liutaifeng. All rights reserved.
//

#import "LTFFirstTableViewCell.h"
#import "IsNight.h"
#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height
@implementation LTFFirstTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}


- (void)createView {
    //高为120
    //图片
    self.picImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:_picImageView];
    //_picImageView.backgroundColor = [UIColor redColor];
    [_picImageView release];
    
    //标题
    self.titleLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_titleLabel];
    //_titleLabel.backgroundColor = [UIColor redColor];
    [_titleLabel release];
    
    //内容
    self.contentLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_contentLabel];
    _contentLabel.textColor = [UIColor grayColor];
    [_contentLabel release];
    
    
    
    //跟帖数
    self.countLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_countLabel];
    _countLabel.textColor = [UIColor grayColor];
    self.countLabel.textAlignment = NSTextAlignmentRight;
    [_countLabel release];
    
}
- (void)layoutSubviews {
    [super layoutSubviews];
    if ([IsNight nowIsNight]) {
        self.contentView.backgroundColor = [IsNight nightColor];
        _titleLabel.textColor = [IsNight textNightColor];
        _contentLabel.textColor = [IsNight textNightColor];
        _countLabel.textColor = [IsNight textNightColor];
        
    }
    else {
        self.contentView.backgroundColor = [UIColor whiteColor];
        _titleLabel.textColor = [UIColor blackColor];
        _contentLabel.textColor = [UIColor blackColor];
        _countLabel.textColor = [UIColor blackColor];
    }
    //图片位置
    self.picImageView.frame = CGRectMake(10, 10, WIDTH / 3, HEIGHT - 20);
    //标题位置
    self.titleLabel.frame = CGRectMake(WIDTH / 3 + 20, 10, WIDTH / 3 * 2 - 20, HEIGHT / 3 - 5);
    //内容位置
    self.contentLabel.frame = CGRectMake(WIDTH / 3 + 20, HEIGHT / 3 + 10, WIDTH / 3 * 2 - 30, HEIGHT / 3 - 5);
    self.contentLabel.font = [UIFont systemFontOfSize:15];
    //文字自适应
    _contentLabel.numberOfLines = 0;
    [_contentLabel sizeToFit];
    //跟帖数自适应
    self.countLabel.frame = CGRectMake(WIDTH - 100, HEIGHT / 3 * 2 + 5, WIDTH / 5 + 5, HEIGHT / 3 - 10);
    self.countLabel.font = [UIFont systemFontOfSize:15];
}
- (void)dealloc
{
    [_picImageView release];
    [_titleLabel release];
    [_contentLabel release];
    [_countLabel release];
    [super dealloc];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
